import App from './App'
import cardInput from "@/modules/cardInput.js"

// var requestUrl="http://172.20.16.2:8020/InterfaceProxy";
var requestUrl="http://xwxrmyygh.cn/InterfaceProxy";
// var wecharUrl="http://127.0.0.1:8080/wechat";
var wecharUrl="http://xwxrmyygh.cn/wechat";

var postJson=function(url,data,fun){
	data.zdbh00="wxpay";
	let dataAll={
		"ver":"1.0",
		"reqsys":"11",
		"reqarea":"11",
		"recsys":"12",
		"recarea":"11",
		"sid":"Gzzxyl.qnhs.hsxrmyy",
		"usr":"hsxrmyysst",
		"pwd":"ZlCOcFyswemqpFG7+lbbUg==",
		"funid":data.funid,
		"body":data
	}
	delete data.funid;
	uni.request({
		url:requestUrl+url,
		header:{
			"Content-type":"application/json"
		},
		data:dataAll,
		dataType:"json",
		method:"POST",
		success:function(res){
			if(res.data.state){
				fun(res.data);
			}else{
				fun(res);
			}
			
		},fail:function(err){
			uni.showToast({
				duration:2000,
				title:"请求异常，网络通讯异常！",
				icon:"none"
			})
		}
	})
}
var postJson2=function(url,data,fun){
	let dataAll=data;
	uni.request({
		url:wecharUrl+url,
		data:dataAll,
		dataType:"json",
		method:"POST",
		success:function(res){
			if(res.data.state){
				fun(res.data);
			}else{
				fun(res);
			}
		},fail:function(err){
			uni.showToast({
				duration:2000,
				title:"请求异常，网络通讯异常！",
				icon:"none"
			})
		}
	})
}
var post=function(url,data,fun){
	let dataAll=data;
	uni.request({
		url:wecharUrl+url,
		header:{
			'content-type': 'application/x-www-form-urlencoded'
		},
		data:dataAll,
		dataType:"json",
		method:"POST",
		success:function(res){
			if(res.data.state){
				fun(res.data);
			}else{
				fun(res);
			}
		},fail:function(err){
			uni.showToast({
				duration:2000,
				title:"请求异常，网络通讯异常！",
				icon:"none"
			})
		}
	})
}

var get=function(url,data,fun){
	delete data.funid;
	uni.request({
		url:wecharUrl+url,
		header:{
			"Content-type":"x-www-form-urlencoded"
		},
		data:dataAll,
		dataType:"json",
		method:"get",
		success:function(res){
			if(res.data.state){
				fun(res.data);
			}else{
				fun(res);
			}
		},fail:function(err){
			uni.showToast({
				duration:2000,
				title:"请求异常，网络通讯异常！",
				icon:"none"
			})
		}
	})
}
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
Vue.mixin({
	methods: {
		$postJson: postJson,
		$postJson2:postJson2,
		$get:get,
		$post:post,
		$cardInput:cardInput
	},
})
const app = new Vue({
    ...App
})

app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
	
  const app = createSSRApp(App);
	app.mixin({
	  methods: {
		$postJson: postJson,
		$postJson2:postJson2,
		$get:get,
		$post:post
	  }})
	 
  return {
    app
  }
}
// #endif
